// ActionScript file
import mx.controls.ColorPicker;
import mx.controls.TextArea;
import mx.controls.ComboBox;
import mx.controls.NumericStepper;

public function texttool():DisplayObject{
	var vbox_t:VBox=new VBox();
	vbox_t.id='bvb';
	vbox_t.percentWidth=100;
	vbox_t.percentHeight=100;
	vbox_t.setStyle("horizontalCenter", 0);

	var l1:Label = new Label();
	l1.text = "输入文字";
	l1.setStyle("horizontalCenter", 0);
	l1.id = "l1";
			
	vbox_t.addChild(l1);
	var ta1:TextArea = new TextArea();
	ta1.setStyle("horizontalCenter", 0);
	ta1.id = "ta1";
	vbox_t.addChild(ta1);
	var cp1:ColorPicker = new ColorPicker();
	cp1.setStyle("horizontalCenter", 0);
	cp1.id = "cp1";
	vbox_t.addChild(cp1);
	var cb1:ComboBox = new ComboBox();
	cb1.setStyle("horizontalCenter", 0);
	//var allFonts:ArrayCollection = new ArrayCollection();
	allFonts = getlocalfont();
	cb1.dataProvider = allFonts;
	cb1.width = 150;
	cb1.id = "cb1";
	vbox_t.addChild(cb1);
	//trace(allFonts);
	var ns1:NumericStepper = new NumericStepper();
	ns1.minimum = 1;
	ns1.maximum = 100;
	ns1.value = 12;
	ns1.setStyle("horizontalCenter", 0);;
	ns1.id = "ns1";
	vbox_t.addChild(ns1);
	var btn1:Button = new Button();
	btn1.label = "添加";
	btn1.addEventListener(MouseEvent.CLICK, function ():void{
		//addText(ta1.text,cp1.value,cb1.selectedItem,ns1.value);
		canvas1(loadedSM.application).addText(ta1.text,cp1.value,cb1.selectedItem,ns1.value);
		this.isOPT = 3;
	});
	vbox_t.addChild(btn1);
	
	return vbox_t;
}

/**
 * 返回本地字体列表
 */
private function getlocalfont():ArrayCollection{
	var arr : Array = Font.enumerateFonts(false);
	var resut : ArrayCollection = new ArrayCollection();
	for(var i : uint = 0 ; i < arr.length ; i++)
	{
		var child : Font = arr[i] as Font;
		resut.addItem(child.fontName);
	}
	
	return resut;
}


